from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client

secret_id = 'AKIDUlqkjUoKaw7TaSOyUnqdAVcV8Yliop20'  # 替换为用户的 secretId
secret_key = 'tWu50gqm9H9ey3tVtgEXaPQFo9F6h04u'  # 替换为用户的 secretKey
region = 'ap-beijing'  # 替换为用户的 Region

token = None  # 使用临时密钥需要传入 Token，默认为空，可不填
scheme = 'https'  # 指定使用 http/https 协议来访问 COS，默认为 https，可不填
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key)

client = CosS3Client(config)

response = client.upload_file(
    Bucket='fengting-0913-1301485706',
    LocalFilePath='default.jpg',  # 本地文件的路径
    Key='p1.jpg', #  上传到桶之后的文件名
)
print(response['ETag'])
